from django.contrib import admin
from django.urls import path, include
from .views import StudentViewSet,ClassViewSet
from rest_framework.routers import DefaultRouter #自动定义路由
urlpatterns = [
    #get请求时使用StudentSerializer的list方法
    #post==》create
    #get==> retrieve
    #put==> update
    #delete==>destory
    # 127.0.0.1:8000/drfstudy/students
    # path('students/',StudentViewSet.as_view({"get":"list","post":"create"})),
    # path('students/<pk>/',StudentViewSet.as_view({"get":"retrieve","put":"update","delete":"destroy"})),

]

router = DefaultRouter() #创建路由对象
router.register('students',StudentViewSet)#设置请求路由
router.register('classes',ClassViewSet)#设置请求路由
urlpatterns += router.urls